package com.opc.repository;

import com.opc.entity.Device;
import com.opc.mapper.DeviceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author SEG
 */
@Repository
public class DeviceRepository {
    @Autowired
    private DeviceMapper deviceMapper;

    public Map<String, Device> getAllDevicesByLine(String line) {
        Map<String, Device> map = new HashMap<>();
        List<Device> list = deviceMapper.getAllDevicesByLine(line);
        for (Device device : list) {
            map.put(device.getDeviceCode(), device);
        }
        return map;
    }
}
